<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;

?>
<div class="row">
    <div class="container lh30">
        <a class="topNav" href="<?=Url::toRoute('/system/site/index')?>"><img src="<?=Yii::getAlias('@web/backend/img/home/home.png');?>" alt="首页"/>返回首页</a>
    </div>
</div>

<div class="row nav-brand-bg borB">
    <div class="container lh30">
        <ul class="nav nav-tabs">
            <li><a href="<?=Url::toRoute(['repertory/repertorymanage']) ?>" style="">库存管理</a></li>
            <li class="active"><a href="<?=Url::toRoute(['repertoryinc/storage']) ?>" style="">商品入库</a></li>
            <li><a href="<?=Url::toRoute(['goodsdec/repertoryout','type' => 1]) ?>">商品出库</a></li>
            <li><a href="<?=Url::toRoute(['repertoryinc/increcord']) ?>">入库流水</a></li>
            <li><a href="<?=Url::toRoute(['goodsdec/decrecord']) ?>">出库流水</a></li>
        </ul>
    </div>
</div>

<div class="container">
    <div class="mg20-y lh45 clearfix" style=" word-spacing: -6px;">
        <a class="btnBg text-center lh45 repertory_add mr20" title="添加新产品" dhref="<?=Url::toRoute(['repertory/add']) ?>" href="javascript:void(0)">
            <img src="<?=Yii::getAlias('@web/backend/img/stocks/add_shop.png');?>"/>添加新商品</a>
        <a class="btnBg dis text-center lh45 repertory_list" title="增加库存" dhref="<?=Url::toRoute(['repertory/list','type' => -1]) ?>" href="javascript:void(0)">
            <img src="<?=Yii::getAlias('@web/backend/img/stocks/iconfont-xiugaikucun.png');?>"/>增加库存</a>
        <span class="mg20-x">扫码枪入库</span>
        <div style="position: relative;display: inline-block;">
            <input type="text" placeholder="" class="code" style="width: 303px;height: 45px;"/>
            <img style="position: absolute;right: 10px;top:50%;margin-top: -10px;" src="<?=Yii::getAlias('@web/backend/img/reportryinc/scan_ico.png');?>" alt=""/>
        </div>
    </div>
    <?php if(empty($repertory)){?>
    <table class="table table-bordered mt20" style="table-layout: fixed;">
        <thead>
        <tr>
            <th>商品名称</th>
            <th>规格</th>
            <th>库存</th>
            <!-- 店长 -->
            <?php if($this->userinfo->user_type == 4){?>
            <th>零售价</th>
            <?php }?>
            <th>入库数量</th>
            <th>供应商</th>
            <th>品牌</th>
            <th>系列</th>
            <th>类别</th>
            <?php if($this->userinfo->user_type == 3){?>
            <th>成本价</th>
            <th>零售价</th>
            <?php }?>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td <?php if($this->userinfo->user_type == 4){?>colspan="10"<?php }else{?>colspan="11"<?php }?> align="center"><img src="<?=Yii::getAlias('@web/backend/img/nodata.gif');?>"></td>
        </tr>
        </tbody>
    </table>

    <?php }else{?>
    <?php ActiveForm::begin(['action'=>Url::toRoute('repertoryinc/storage'),'options'=>['name'=>'myform']])?>
    <table class="table table-bordered mt20" style="table-layout: fixed;">
        <thead>
        <tr>
            <th>商品名称</th>
            <th>规格</th>
            <th>库存</th>
            <!-- 店长 -->
            <?php if($this->userinfo->user_type == 4){?>
            <th>零售价</th>
            <?php }?>
            <th>入库数量</th>
            <th>供应商</th>
            <th>品牌</th>
            <th>系列</th>
            <th>类别</th>
            <?php if($this->userinfo->user_type == 3){?>
            <th>成本价</th>
            <th>零售价</th>
            <?php }?>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($repertory as $r){?>
        <tr>
            <input id="rid" type="hidden" name="repertory_id[]" value="<?=Html::encode($r['repertory_id']) ?>" readonly/>
            <td><input class="read-only" type="text" name="goods_name[]" value="<?=Html::encode($r['repertory_name']) ?>" readonly/></td>
            <td><input class="read-only" type="text" name="goods_specs[]" value="<?=Html::encode($r['repertory_specs']) ?>" readonly/></td>
            <td><input class="read-only" type="text" name="repertory_count[]" value="<?=Html::encode($r['repertory_count']) ?>" readonly/></td>
            <?php if($this->userinfo->user_type == 4){?>
            <td><input class="read-only" type="text" name="goods_sell_price[]" value="<?=Html::encode($r['goods_sell_price']) ?>" readonly/></td>
            <?php }?>
            <td><input type="text" name="inc_count[]"  value="<?php if(isset($r[0])){?><?=Html::encode($r[0]) ?><?php }?>" class="inc_num"/></td>
            <td><input class="read-only" type="text" name="supplier_name[]" value="<?=Html::encode($r['supplier_name']) ?>" readonly/></td>
            <td><input class="read-only" type="text" name="goods_brand[]" value="<?=Html::encode($r['repertory_brand']) ?>" readonly/></td>
            <td><input class="read-only" type="text" name="goods_series[]" value="<?=Html::encode($r['repertory_series']) ?>" readonly/></td>
            <td><input class="read-only" type="text" name="goods_category[]" value="<?=Html::encode($r['repertory_category']) ?>" readonly/></td>
            <?php if($this->userinfo->user_type == 3){?>
            <td><input type="text" name="goods_cost_price[]" value="<?=Html::encode($r['goods_cost_price']) ?>"/></td>
            <td><input type="text" name="goods_sell_price[]" value="<?=Html::encode($r['goods_sell_price']) ?>"/></td>
            <?php }?>
            <td><a href="<?=Url::toRoute(['repertory/delselect','id' => $r['repertory_id'],'type' => 1]) ?>" class="del red btn btn-sm btn-borB4">删除</a></td>
        </tr>
        <?php }?>
        <tr class="tips">
            <td class="text-center" <?php if($this->userinfo->user_type == 4){?>colspan="10"<?php }else{?>colspan="11"<?php }?>>
            共计数量：
            <em class="red" id="red">0件</em>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="clearfix mt20">
        <label class="pull-left mr10">备注</label>
        <div class="pull-left">
            <textarea style="vertical-align: text-top; resize: none; width: 1365px; max-width: 1365px; height: 180px; max-height: 180px; padding: 10px;" name="inc_remark"></textarea>
            <button type="submit" class="btnBg mt20" style="display: block;">提交</button>
            <!--  <a class="btnBg mt20" href="" style="display: block;">提交</a>  -->
        </div>
    </div>
    <?php ActiveForm::end();?>
    <?php }?>
</div>

<?php $this->registerJsFile("@web/system/repertoryinc/storage.js",['position'=>$this::POS_END]);?>
